#include <cstdio>
#include <iostream>
using namespace std;
int n,L,R;
//n boys, from L to R
int main(){
	FILE *fin,*fout;
	fin=fopen("candy.in","rb");
	fout=fopen("candy.out","wb");
	//fin=stdin,fout=stdout;
	fscanf(fin,"%d%d%d",&n,&L,&R);
	if(2*n>R){
		fprintf(fout,"%d",R-n);
		return 0;
	}
	if(R%n==0){
		fprintf(fout,"%d",(R-1)%n);
		return 0;
	}
	if(L==R){
		fprintf(fout,"%d",L%n);
		return 0;
	}
	if(L-R<=n){
		int i=1;
		while(i*n<R){
			i++;
		}
		int k=(i-1)*n-1;
		if(k<L){
			fprintf(fout,"%d",R%n);
		}else if(k>L&&k<R){
			fprintf(fout,"%d",k%n);
		}
		
	}else{
		for(int i=L/n;i<=(R/n);i++){
			int k=i*n-1;
			if(k>=L&&k<=R){
				fprintf(fout,"%d",k%n);
				return 0;
			}
		}
	}
	fclose(fin);
	fclose(fout);
	return 0;
} 
